package io.datajek.springbasics.movierecommendersystem.lesson11;

//寻找电影

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component("CBF")
public class ContentBasedFilter implements Filter {

    private Logger logger =
            LoggerFactory.getLogger(this.getClass());

    public ContentBasedFilter() {
        super();
        logger.info("In ContentBasedFilter constructor method");
    }

    @PostConstruct
    private void postConstruct() {
        //将电影加载到缓存中
        logger.info("In ContentBasedFilter postConstruct method");
    }

    //寻找相关电影的所有步骤都在这个方法中进行
    public String[] getRecommendations(String movie){

        return new String[] {"Happy Feet", "Ice Age", "Shark Tale"};
    }

    @PreDestroy
    private void preDestroy() {
        //从缓存中清除电影
        logger.info("In ContentBasedFilter preDestroy method");
    }

}
